package com.lagou.homeWork4.hw1;

import java.util.List;

public class StudentDel {
    public static void deleteStudent(int id, List<Student> listStudents) {
        // 遍历学生对象List
        for (Student st : listStudents) {
            // 获取当前对象索引
            int index = listStudents.indexOf(st);
            // 如果当前对象id等于目标id
            if (id == st.getId()) {
                listStudents.remove(index);
                System.out.println("删除成功！");
            }
        }
    }
}
